import allure
import pymysql
import requests

# http请求
@allure.step('2.发送请求')
def send_http_request(request_data):
    res = requests.request(**request_data)
    return res

# 向数据库发送请求并返回响应信息
def send_jdbc_request(sql,index=0):# fecthone()返回的是元组，通过index=0索引默认进行取出第一个
    conn = pymysql.connect(
        host='192.168.10.131',
        port=3306,
        database='mydb',
        user='root',
        passwd='123456',
        charset='utf8'
    )
    cur = conn.cursor()
    cur.execute(sql)
    result = cur.fetchone()
    cur.close()
    conn.close()
    return result[index]



